/**
 * API 接口统一管理
 */
import http from "../utils/http";

// 用户相关接口
export const userApi = {
  // 用户名是否存在
  checkUserNameApi: (data) => http.post("/user/check_user_name", data),

  // 手机号是否存在
  checkPhoneApi: (data) => http.post("/user/check_phone", data),

  // 注册
  registerApi: (data) => http.post("/user/register", data),

  // 用户名登录
  loginApi: (data) => http.post("/user/login", data),

  // 刷新令牌
  refreshTokenApi: (data) => http.post("/user/refresh_token", data),

  // 获取用户信息
  getUserInfoApi: () => http.post("/user/info"),

  // 编辑用户信息
  editUserInfoApi: (data) => http.post("/user/edit_info", data),

  // 实名认证
  realNameAuthApi: (data) => http.post("/user/real_name_auth", data),

  // 获取验证码
  getCodeApi: (data) => http.post("/user/get_code", data),

  //检验手机验证码
  checkPhoneCodeApi: (data) => http.post("/user/check_phone_code", data),

  // 验证码登录
  loginCodeApi: (data) => http.post("/user/login_code", data),

  // 换绑手机号
  bindPhoneApi: (data) => http.post("/user/bind_phone", data),

  // 获取邮箱验证码
  getCodeByEmailApi: (data) => http.post("/user/get_code_by_email", data),

  // 换绑邮箱
  bindEmailApi: (data) => http.post("/user/bind_email", data),

  // 用户支付密码设置
  payPwdAddApi: (data) => http.post("/user/pay_pwd_add", data),

  // 用户支付密码修改
  payPwdUpdateApi: (data) => http.post("/user/pay_pwd_update", data),

  // 用户支付密码重置
  payPwdResetApi: (data) => http.post("/user/pay_pwd_reset", data),

  // 用户支付密码校验
  payPwdCheckApi: (data) => http.post("/user/pay_pwd_check", data),

  // 发送短信验证码
  sendSmsCodeApi: (data) => http.post("/user/send_sms_code", data),

  // 验证短信验证码
  verifySmsCodeApi: (data) => http.post("/user/verify_sms_code", data),

  // 手机号注册
  registerByPhoneApi: (data) => http.post("/user/register_by_phone", data),

  //修改登录密码-新密码
  updateLoginPasswordApi: (data) => http.post("/user/update_login_pwd", data),

  //修改登录密码-校验原密码
  checkLoginPasswordApi: (data) => http.post("/user/check_login_pwd", data),
};

// 钱包相关接口
export const walletApi = {
  // 查询用户钱包余额
  getBalanceApi: (data) => http.post("/wallet/balance", data),

  // 查询用户钱包地址
  getAddrApi: (data) => http.post("/wallet/addr", data),

  // 创建用户提现订单
  withdrawalApi: (data) => http.post("/wallet/withdrawal", data),

  // 对账-获取用户日度资金变动记录
  getDailyFlowApi: (data) => http.post("/wallet/daily_flow", data),

  // 查询用户所有钱包余额
  getBalanceAllApi: (data) => http.post("/wallet/balance_all", data),

  // 验证钱包地址
  verifyAddressApi: (data) => http.post("/wallet/verify_address", data),

  // 用户提现订单列表
  getWithdrawalListApi: (data) => http.post("/order/withdrawal_list", data),

  // 用户提现订单详情
  getWithdrawalInfoApi: (data) => http.post("/order/withdrawal_info", data),
};

// 订单相关接口
export const orderApi = {};

// 商户相关接口
export const merchantApi = {
  // 获取提现手续费信息
  getCommissionApi: () => http.post("/merchant/commission"),
};

// 支付相关接口
export const payApi = {
  // 添加收款方式
  addMethodsApi: (data) => http.post("/pay/add_methods", data),

  // 收款方式列表
  getListApi: (data) => http.post("/pay/list", data),

  // 获取收款方式详情
  getMethodsApi: (data) => http.post("/pay/detail", data),

  // 编辑收款方式
  editMethodsApi: (data) => http.post("/pay/edit", data),

  // 删除收款方式
  deleteMethodsApi: (data) => http.post("/pay/delete", data),
};

// 银行卡相关接口
export const bankCardApi = {
  // 添加银行卡
  addBankCardApi: (data) => http.post("/bank_card/add", data),

  // 获取银行卡列表
  getBankCardListApi: (data) => http.post("/bank_card/list", data),

  // 获取银行卡详情
  getBankCardDetailApi: (data) => http.post("/bank_card/detail", data),

  // 编辑银行卡
  editBankCardApi: (data) => http.post("/bank_card/edit", data),

  // 删除银行卡
  deleteBankCardApi: (data) => http.post("/bank_card/delete", data),

  // 获取支持的银行列表
  getSupportedBanksApi: () => http.post("/bank_card/supported_banks"),

  // 验证银行卡号
  validateCardNumberApi: (data) => http.post("/bank_card/validate", data),
};

// 公告相关接口
export const noticeApi = {
  // 公告列表
  getListApi: (data) => http.post("/notice/list", data),

  // 公告详情
  getDetailApi: (data) => http.post("/notice/detail", data),
};

// 广告相关接口
export const adApi = {
  // 广告列表
  getListApi: (data) => http.post("/advert/list", data),

  // 广告详情
  getDetailApi: (data) => http.post("/advert/detail", data),
};

// 留言相关接口
export const messageApi = {
  // 创建留言
  createApi: (data) => http.post("/message/create", data),

  // 留言详情
  getDetailApi: (data) => http.post("/message/detail", data),

  // 留言列表
  getListApi: (data) => http.post("/message/list", data),
};

// 申诉相关接口
export const appealApi = {
  // 创建申诉
  createApi: (data) => http.post("/appeal/create", data),

  // 申诉列表
  getListApi: (data) => http.post("/appeal/list", data),

  // 申诉详情
  getDetailApi: (data) => http.post("/appeal/detail", data),

  // 申诉回复
  replyApi: (data) => http.post("/appeal/reply", data),

  // 申诉取消
  cancelApi: (data) => http.post("/appeal/cancel", data),
};

// 兑换相关接口
export const exchangeApi = {
  // 创建兑换订单
  createOrderApi: (data) => http.post("/otc/exchange", data),

  // 获取兑换订单详情
  getDetailApi: (data) => http.post("/otc/exchange_detail", data),

  // 获取兑换订单列表
  getExchangeListApi: (data) => http.post("/otc/exchange_list", data),
};

// 买卖平台相关接口
export const platformApi = {
  // 平台购买/出售-产品列表
  getProductListApi: (data) => http.post("/otc/product_list", data),

  // 平台购买-下单
  purchaseApi: (data) => http.post("/otc/platform_purchase", data),

  // 平台购买订单列表
  getOrderListApi: (data) => http.post("/otc/platform_order_list", data),

  // 平台购买订单详情
  getOrderDetailApi: (data) => http.post("/otc/platform_order_detail", data),

  // 平台订单-取消
  cancelOrderApi: (data) => http.post("/otc/platform_order_cancel", data),

  // 平台出售-出售下单
  sellApi: (data) => http.post("/otc/platform_sell", data),

  // 平台出售订单列表
  getSellOrderListApi: (data) =>
    http.post("/otc/platform_sell_order_list", data),

  // 平台出售订单详情
  getSellOrderDetailApi: (data) =>
    http.post("/otc/platform_sell_order_detail", data),

  // 获取所有价格
  getPriceApi: () => http.post("/otc/price"),
};

// 公共接口
export const publicApi = {
  // 获取支付方式
  getPaymentMethodsApi: () => http.post("/public/get_payment_methods"),
};

// OTC C2C相关接口
export const otcApi = {
  // 创建 make 单
  userActionApi: (data) => http.post("/otc/c2c_user_action", data),

  // 查询用户关联OTC订单列表
  getUserOrdersListApi: (data) => http.post("/otc/c2c_user_orders_list", data),

  // 查询所有OTC挂单列表
  getOpenMakeListApi: (data) =>
    http.post("/otc/c2c_orders_open_make_list", data),
  //查询订单详情
  getOtcListDetailApi: (data) => http.post("/otc/get_order_list", data),
  //审核make订单列表
  getAuditMakeListApi: (data) => http.post("/otc/c2c_make_order_list", data),
  //审核make订单详情
  getAuditMakeDetailApi: (data) =>
    http.post("/otc/c2c_make_order_detail", data),
  //取消make订单审核
  cancelAuditMakeApi: (data) => http.post("/otc/c2c_make_order_cancel", data),
};

// 文件上传接口
export const uploadApi = {
  uploadFile: (data) => http.post("/file/upload", data),
};

// 扫码支付相关接口
export const scanPayApi = {
  // 商户创建支付订单-下单
  userPurchaseApi: (data) => http.post("/otc/user_purchase", data),

  //支付订单状态-回调（商户提供）
  payCallbackApi: (data) => http.post("/pay_callback", data),

  // 用户支付订单-详情
  getUserPurchaseOrderDetailApi: (data) => http.post("/otc/user_purchase_order_detail", data),

  // 用户支付订单-支付
  userPurchaseOrderPayApi: (data) => http.post("/otc/user_purchase_order_pay", data),

  // 用户支付订单列表
  getUserPurchaseOrderListApi: (data) => http.post("/otc/user_purchase_order_list", data),
};

// 导出所有API
export default {
  user: userApi,
  wallet: walletApi,
  order: orderApi,
  merchant: merchantApi,
  pay: payApi,
  bankCard: bankCardApi,
  notice: noticeApi,
  message: messageApi,
  appeal: appealApi,
  exchange: exchangeApi,
  platform: platformApi,
  public: publicApi,
  otc: otcApi,
  upload: uploadApi,
  ad: adApi,
  scanPay: scanPayApi,
};
